export abstract class BasicDecoder {
  public abstract decode(buffer: ArrayBuffer): Map<string, number>;

  isJsonString(str) {
    if (typeof str == 'string') {
      try {
        var obj = JSON.parse(str);
        if (typeof obj == 'object' && obj) {
          return true;
        } else {
          return false;
        }
      } catch (e) {
        console.log('error：' + str + '!!!' + e);
        return false;
      }
    }
    console.log('It is not a string!');
    return false;
  }

  arrayBufferToString(buffer): string {
    return String.fromCharCode.apply(null, new Uint8Array(buffer))
  }
}